home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / graphics / snap.lzh / SNAP.S next >
Text File  |  1991-03-03  |  4KB  |  125 lines

  1. ***********************************************************
  2. *    Degas snapshot utility v1 - Save screen if:      *
  3. *    Control+Alternate+both Shift keys held down      *
  4. *    Written using HiSoft Devpac              *
  5. *    Last modified 22/02/90    (c) 1990 by M.Murray      *
  6. ***********************************************************
  7.  
  8. * Display start-up message
  9.     PEA message(PC)        string address
  10.     MOVE #9,-(A7)        c_conws
  11.     TRAP #1            GEMDOS
  12.     ADDQ.L #6,A7        tidy stack
  13.     MOVE #500,D0        delay loop
  14. delay1    MOVE #1000,D1        waste time by doing sums!
  15. delay2    MOVE #-1,D2
  16.     MULU D2,D2
  17.     DBRA D1,delay2
  18.     DBRA D0,delay1
  19.  
  20. * Call revect in supervisor mode to alter TRAP #13 vector
  21.     PEA revect(PC)        stack address of subroutine
  22.     MOVE #$26,-(SP)        superx
  23.     TRAP #14        XBIOS
  24.     ADDQ.L #6,A7        restore stack
  25.  
  26. * Exit to desktop, but keep program in memory
  27.     MOVE.L 4(A7),A5        Get basepage address in A5
  28.     MOVE.L $C(A5),D0    get text segment size in D0
  29.     ADD.L $14(A5),D0    add data segment size
  30.     ADD.L $1C(A5),D0    add uninitialised bit
  31.     ADD.L #$100,D0        add basepage size
  32.     CLR -(A7)        exit code = 0
  33.     MOVE.L D0,-(A7)        number of bytes to keep
  34.     MOVE #49,-(A7)        p_termres
  35.     TRAP #1            GEMDOS
  36.  
  37. * Revector TRAP #13 through my code (in supervisor mode)
  38. revect    LEA oldtrap(PC),A0
  39.     MOVE.L $B4,(A0)        copy TRAP #13 vector to oldtrap
  40.     LEA code(PC),A0
  41.     MOVE.L A0,$B4        insert code address into TRAP #13
  42.     RTS
  43.  
  44. * All TRAP #13 calls now pass through here
  45. code    MOVEM.L D0-D3/A0-A3,-(A7)    Save registers
  46.     LEA flag(PC),A3        A0 -> flag
  47.     TAS (A3)        routine on or off?
  48.     BNE exit        IF flag<>0 THEN exit
  49.     MOVE #-1,-(A7)        read keyboard shift bits
  50.     MOVE #11,-(A7)        kbshift
  51.     TRAP #13        Gem Bios
  52.     ADDQ.L #4,A7        tidy stack
  53.     ANDI #15,D0        bits 0/1/2/3 are key status
  54.     CMPI #15,D0        all pressed?
  55.     BNE quit        quit if not
  56.  
  57. * This code is executed if all keys are pressed
  58.     MOVE #4,-(A7)        _getrez...in D0
  59.     TRAP #14        XBIOS
  60.     ADDQ.L #2,A7        tidy stack
  61.     LEA header(PC),A0    A0 -> header
  62.     MOVE D0,(A0)        put resolution in 1st word of header
  63.     LEA name(PC),A0        A0 -> filename
  64.     ADDQ.B #1,5(A0)        increment letter in filename SNAP_?.PI?
  65.     ADDI #49,D0        make res into '1'/'2'/'3'
  66.     MOVE.B D0,9(A0)        put resolution in name...PI1-PI3
  67.  
  68.     CLR -(A7)        filespec = 0 = read/write
  69.     PEA name(PC)        filename
  70.     MOVE #60,-(A7)        f_create.....create file
  71.     TRAP #1            GEMDOS
  72.     ADDQ.L #8,A7        tidy stack
  73.     MOVE D0,D3        save file handle in D3
  74.  
  75.     PEA palette(PC)        get palette in supervisor mode
  76.     MOVE #38,-(A7)        superx
  77.     TRAP #14        XBIOS
  78.     ADDQ.L #6,A7        tidy stack
  79.  
  80.     PEA header(PC)        address of memory to save
  81.     MOVE.L #34,-(A7)    34 bytes to write
  82.     MOVE D3,-(A7)        file handle
  83.     MOVE #64,-(A7)        f_write.....save header
  84.     TRAP #1            GEMDOS
  85.     ADDA.L #12,A7        tidy stack
  86.  
  87.     MOVE #2,-(A7)        _physbase...in D0
  88.     TRAP #14        XBIOS
  89.     ADDQ.L #2,A7        tidy stack
  90.     MOVE.L D0,-(A7)        screen address
  91.     MOVE.L #32000,-(A7)    32k to save
  92.     MOVE D3,-(A7)        file handle
  93.     MOVE #64,-(A7)        f_write.....save screen
  94.     TRAP #1            GEMDOS
  95.     ADDA.L #12,A7        tidy stack
  96.  
  97.     MOVE D3,-(A7)        file handle
  98.     MOVE #62,-(A7)        f_close.....close file
  99.     TRAP #1            GEMDOS
  100.     ADDQ.L #4,A7        tidy stack
  101.  
  102. quit    CLR.B (A3)        reset flag to turn routine back on
  103. exit    MOVEM.L (A7)+,D0-D3/A0-A3    Restore registers
  104.     DC.W $4EF9        JMP $xxxxxxxx - old vector address
  105. oldtrap    DC.L 0
  106.  
  107. ***********************************************************
  108. * Subroutine to get the palette in supervisor mode
  109. ***********************************************************
  110. palette    LEA header+2(PC),A0    A1 -> header+2
  111.     LEA $FF8240,A1
  112.     MOVE #7,D0
  113. ploop    MOVE.L (A1)+,(A0)    copy palette into header
  114.     ANDI.L #$07770777,(A0)+    mask off unwanted bits
  115.     DBRA D0,ploop
  116.     RTS
  117.  
  118. flag    DC.W 0            flag for switching routine on/off
  119. name    DC.B 'SNAP_@.PI1',0    filename
  120.     EVEN
  121. header    DS.W 17            Degas header...34 bytes
  122. message    DC.B 13,10,' Snap v1.0 is now installing...',13,10
  123.     DC.B 13,10,' Press: Control + Alternate + both'
  124.     DC.B 13,10,' Shift keys to save the screen...',0
  125.